package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.IndentDetailBean;
import com.lwj.liwanjia.impl.IndentDetailView;
import com.lwj.liwanjia.model.IndentDeatilModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/20.
 */

public class IndentDetailPresenter {
    private IndentDeatilModel indentDeatilModel;
    private IndentDetailView indentDetailView;

    public IndentDetailPresenter(IndentDetailView indentDetailView) {
        this.indentDetailView = indentDetailView;
        indentDeatilModel = new IndentDeatilModel();
    }

    public void getIndentDetailData(String token, String tradeId) {
        if (indentDetailView != null) {
            indentDeatilModel.getIndentDetailData(token, tradeId, new Subscriber<IndentDetailBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    indentDetailView.showError((Exception) e);
                }

                @Override
                public void onNext(IndentDetailBean indentDetailBean) {
                    indentDetailView.getIndentDetailData(indentDetailBean);
                }
            });
        }
    }
}
